﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Account/Site.master" AutoEventWireup="true" CodeFile="ChiTietDonHang.aspx.cs" Inherits="Administrator_ChiTietDonHang" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" 
        Font-Size="0.8em" PathSeparator=" : " style="font-size: small">
        <CurrentNodeStyle ForeColor="#333333" />
        <NodeStyle Font-Bold="True" ForeColor="#284E98" />
        <PathSeparatorStyle Font-Bold="True" ForeColor="#507CD1" />
        <RootNodeStyle Font-Bold="True" ForeColor="#507CD1" />
    </asp:SiteMapPath>
    <br />
    <asp:Label ID="Label1" runat="server" 
        style="font-size: x-large; font-weight: 700" 
        Text="Quản lý chi tiết đơn hàng"></asp:Label>
    <br />
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
        DeleteCommand="DELETE FROM [ChiTietDonHang] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [ChiTietDonHang] ([SanPhamID], [SoLuong], [Gia], [DonHangID]) VALUES (@SanPhamID, @SoLuong, @Gia, @DonHangID)" 
        SelectCommand="SELECT * FROM [ChiTietDonHang] WHERE ([DonHangID] = @DonHangID)
UPDATE [DonHang] SET [TrangThai]=1 WHERE [ID] = @DonHangID" 
        
        UpdateCommand="UPDATE [ChiTietDonHang] SET [SanPhamID] = @SanPhamID, [SoLuong] = @SoLuong, [Gia] = @Gia, [DonHangID] = @DonHangID WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="SanPhamID" Type="String" />
            <asp:Parameter Name="SoLuong" Type="Int32" />
            <asp:Parameter Name="Gia" Type="Double" />
            <asp:Parameter Name="DonHangID" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="DonHangID" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="SanPhamID" Type="String" />
            <asp:Parameter Name="SoLuong" Type="Int32" />
            <asp:Parameter Name="Gia" Type="Double" />
            <asp:Parameter Name="DonHangID" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" 
        DataSourceID="SqlDataSource2" EnableModelValidation="True" CellPadding="4" 
        ForeColor="#333333" Width="100%">
        <EditItemTemplate>
            ID:
            <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
            <br />
            NgayGui:
            <asp:TextBox ID="NgayGuiTextBox" runat="server" Text='<%# Bind("NgayGui") %>' />
            <br />
            HoTenKhach:
            <asp:TextBox ID="HoTenKhachTextBox" runat="server" 
                Text='<%# Bind("HoTenKhach") %>' />
            <br />
            DiaChi:
            <asp:TextBox ID="DiaChiTextBox" runat="server" Text='<%# Bind("DiaChi") %>' />
            <br />
            DienThoai:
            <asp:TextBox ID="DienThoaiTextBox" runat="server" 
                Text='<%# Bind("DienThoai") %>' />
            <br />
            Email:
            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
            <br />
            GhiChu:
            <asp:TextBox ID="GhiChuTextBox" runat="server" Text='<%# Bind("GhiChu") %>' />
            <br />
            TrangThai:
            <asp:CheckBox ID="TrangThaiCheckBox" runat="server" 
                Checked='<%# Bind("TrangThai") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <InsertItemTemplate>
            NgayGui:
            <asp:TextBox ID="NgayGuiTextBox" runat="server" Text='<%# Bind("NgayGui") %>' />
            <br />
            HoTenKhach:
            <asp:TextBox ID="HoTenKhachTextBox" runat="server" 
                Text='<%# Bind("HoTenKhach") %>' />
            <br />
            DiaChi:
            <asp:TextBox ID="DiaChiTextBox" runat="server" Text='<%# Bind("DiaChi") %>' />
            <br />
            DienThoai:
            <asp:TextBox ID="DienThoaiTextBox" runat="server" 
                Text='<%# Bind("DienThoai") %>' />
            <br />
            Email:
            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
            <br />
            GhiChu:
            <asp:TextBox ID="GhiChuTextBox" runat="server" Text='<%# Bind("GhiChu") %>' />
            <br />
            TrangThai:
            <asp:CheckBox ID="TrangThaiCheckBox" runat="server" 
                Checked='<%# Bind("TrangThai") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            ID:
            <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
            <br />
            Ngày gửi :
            <asp:Label ID="NgayGuiLabel" runat="server" Text='<%# Bind("NgayGui") %>' />
            <br />
            Họ tên khách hàng :
            <asp:Label ID="HoTenKhachLabel" runat="server" 
                Text='<%# Bind("HoTenKhach") %>' />
            <br />
            Địa chỉ :
            <asp:Label ID="DiaChiLabel" runat="server" Text='<%# Bind("DiaChi") %>' />
            <br />
            Điện thoại :
            <asp:Label ID="DienThoaiLabel" runat="server" Text='<%# Bind("DienThoai") %>' />
            <br />
            Email :
            <asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email") %>' />
            <br />
            Ghi chú:
            <asp:Label ID="GhiChuLabel" runat="server" Text='<%# Bind("GhiChu") %>' />
            <br />
        </ItemTemplate>
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
        SelectCommand="SELECT * FROM [DonHang] WHERE ([ID] = @ID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" 
        DataSourceID="SqlDataSource1" EnableModelValidation="True" Width="100%" 
        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
        CellPadding="3">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True">
            <ItemStyle Width="20px" />
            </asp:CommandField>
            <asp:BoundField DataField="SanPhamID" HeaderText="Mã sản phẩm" 
                SortExpression="SanPhamID" />
            <asp:BoundField DataField="SoLuong" HeaderText="Số lượng" 
                SortExpression="SoLuong" />
            <asp:BoundField DataField="Gia" HeaderText="Giá" SortExpression="Gia" />
        </Columns>
        <EmptyDataTemplate>
            Đơn hàng này không có sản phẩm
        </EmptyDataTemplate>
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
        <RowStyle ForeColor="#000066" />
        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
    </asp:GridView>
    <br />
</asp:Content>

